﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace ShadowCommando.Game.Utilites
{
    /// <summary>
    /// Klasa opisująca prostą 
    /// </summary>
    class Straight
    {
        private int x1;
        private int x2;
        private int y1;
        private int y2;
        private double a, b, c;
        /// <summary>
        /// Ustaw prostą
        /// </summary>
        /// <param name="_x1">Wsp x1 </param>
        /// <param name="_y1">Wsp y1</param>
        /// <param name="_x2">Wsp x2</param>
        /// <param name="_y2">Wsp y2</param>
        public void Set(int _x1, int _y1, int _x2, int _y2)
        {
            x1 = _x1;
            x2 = _x2;
            y1 = _y1;
            y2 = _y2;
            a = y1 - y2;
            b = x2 - x1;
            c = -y1 * (x2 - x1) + x1 * (y2 - y1);
        }
        /// <summary>
        /// Wartość prostej w pkt x
        /// </summary>
        /// <param name="x">Argument funkcji</param>
        /// <returns></returns>
        public double F(double x)
        {
            double wart = -(a / b) * x - c / b;
            return (int)wart;
        }
    }
}
